package com.songshuai.pangu.api;

import com.songshuai.webapi.common.annotation.RequestJsonHandlerMethodArgumentResolver;
import org.apache.commons.lang3.time.StopWatch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@EnableEurekaClient
@EnableFeignClients
//@EnableHystrix
@SpringBootApplication
//@EnableApolloConfig
public class PanguApiApplication extends WebMvcConfigurerAdapter {
    public static void main(String[] args) {
        StopWatch sw = new StopWatch();
        sw.start();
//        System.setProperty("apollo.configService", "http://118.25.41.11:8080");
        ConfigurableApplicationContext applicationContext = SpringApplication.run(PanguApiApplication.class, args);
        System.out.println(new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]").format(new Date())
                + "PanguApiApplication server started!");
        sw.stop();
        System.out.println("PanguApiApplication Launch Time: " + sw.toString());
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers){
        argumentResolvers.add(new RequestJsonHandlerMethodArgumentResolver());
        super.addArgumentResolvers(argumentResolvers);
    }
}
